<template>
	<view>
		<!-- 顶部导航 -->
		<u-navbar :background="background">
			<view class="ft_16 fw-b">
				核销
			</view>
		</u-navbar>
		<view class="content">
			<view class="con_1 ft_18 fw-b c-999">
				请输入核销码
			</view>
			<view class="con_2">
				<input type="number" v-model="kexiaoma" />
			</view>
			<view class="ft_18 fw-b c-999 con_3" @click="saoma()">
				点击此处扫码核销>>
			</view>
			<view class="ft_16 con_4" @click="confirmHX()">
				确认核销
			</view>
			<view class="c-999" style="text-align: center;" @click="HXjilu()">
				核销记录
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background:{backgroundColor: '#ffffff',}, //导航栏背景
				kexiaoma:"", //核销码
				
			}
		},
		methods: {
			saoma(){ //扫码核销
				let that=this
				uni.scanCode({
					success: function (res) {
						console.log(res);
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						that.kexiaoma=res.result
						that.confirmHX()
					}
				});
			},
			confirmHX(){ //确认核销
				this.$myRequest('order/write_off',{
					code:this.kexiaoma
				}).then(res=>{
					console.log(res.data);
					this.$all.toast(res.data.msg)
					if(res.data.code==1){
						setTimeout(()=>{
							uni.navigateBack()
						},800)
					}
				})
			},
			HXjilu(){ //核销记录
				uni.navigateTo({
					url:"HXjilu"
				})
			},
			
		}
	}
</script>

<style lang="scss">
page{
	background-color: #fafafa;
}
.content{
	padding: 0 15px;
	.con_1{
		padding: 20px 0;text-align: center;
	}
	.con_2{
		padding: 15px;background-color: #FFFFFF;border: 1px solid #eeeeee;
	}
	.con_3{
		padding: 20px 0;text-align: center;color: #E67920 ;
	}
	.con_4{
		padding: 15px 0;margin: 15px 0;text-align: center;background: linear-gradient(90deg, #F1A421 0%, #E4741F 100%);color: #FFFFFF;border-radius: 30px;
	}
	
}

</style>
